package com.jastar.android.game.gobang;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import com.jastar.android.test.R;

public class GameNavigateActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_gobang_game_navigate);
        super.findViewById(R.id.button_1).setOnClickListener(this);
        super.findViewById(R.id.button_2).setOnClickListener(this);
        super.findViewById(R.id.button_3).setOnClickListener(this);
        //super.findViewById(R.id.button_4).setOnClickListener(this);
        super.findViewById(R.id.button_5).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (R.id.button_1 == v.getId()) {
            jumpActivity(GameActivity.class, true, false);
        } else if (R.id.button_2 == v.getId()) {
            jumpActivity(GameActivity.class, true, true);
        } else if (R.id.button_3 == v.getId()) {
            jumpActivity(GameActivity.class, false, false);
        } else if (R.id.button_5 == v.getId()) {
            jumpActivity(com.jastar.android.game.go.GameActivity.class, false, false);
        }
    }

    private void jumpActivity(Class<?> cls, boolean isAI, boolean isMaster) {
        Intent intent = new Intent(this, cls);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.putExtra(GameActivity.SIGN_IS_AI, isAI);
        intent.putExtra(GameActivity.SIGN_IS_MASTER, isMaster);
        super.startActivity(intent);
    }

}